using System;
using ViScript.Core.Argument;
using ViScript.Core.Utils;

namespace ViScript.Core.ParameterRules
{
    public class Int16ParameterRule : IParameterRule
    {
        public IArgument Parse(Type type, IText text, ISentence sentence)
        {
            short result;
            if (Int16.TryParse(text.ToString(), out result))
            {
                return new NormalArgument(result);
            }
            else
            {
                return UnrecognizedArgument.UNRECOGNIZED_ARGUMENT;
            }
        }
    }
}